//index.js
//获取应用实例
const app = getApp()
const Pager = require('components/aotoo/core')


let mkModal = require('components/modules/modal')

Pager({
  data: {
    pages: Pager.list({
      type :{
        is: 'scroll', 
        'scroll-y': true
      },
      data: [
        {
          title: '抽屉 左边',
          body: [
            {title: '半屏', itemClass: 'ss-button btn-default', aim: 'onModal?type=left&animate=true'},
            {title: '全屏', itemClass: 'ss-button btn-default', aim: 'onModal?type=left&animate=true&full=true'},
          ],
         bodyClass: 'btn-footer mt-primary'
        },
        {
          title: '抽屉 右边',
          body: [
            {title: '半屏', itemClass: 'ss-button btn-default', aim: 'onModal?type=right&animate=true'},
            {title: '全屏', itemClass: 'ss-button btn-default', aim: 'onModal?type=right&animate=true&full=true'},
          ],
         bodyClass: 'btn-footer mt-primary'
        },
      ],
      listClass: 'hei-p100',
      itemClass: 'm-default'
    }),
    modal: { id: 'actionSide1' },
    modal2: { id: 'actionSide2' }
  },
  modal: null,
  onModal(e, params, inst) {
    const type = params.type
    const animate = params.animate
    const full = params.full
    this.modal.update(mkModal({
      data: {
        title: [
          {
            title: '标题',
            itemClass: 'title-primary no-lh ss-center mb-default'
          },
          full ? {title: ' ', itemClass: 'icon-close click-icon-width', aim: 'onClose'} : {}
        ],
        body: [{title: '开启微信用户信息授权，即可享受更多服务哦~', itemClass: 'size no-lh-x'}],
        footer: !full ? [ {title: '下一步', itemClass: 'ss-button btn-default', aim: 'onNext?type='+type}] : [],
        footerClass: 'btn-footer mt50',
        titleClass: 'flex-row-between',
      },
      direction: type,
      animate: animate,
      full: full,
    }))
  },
  onNext(e, params, inst){
    const type = params.type
    this.modal2.update(mkModal({
      data: {
        title: {
          title: '提示',
          itemClass: 'title-primary no-lh ss-center mb-default'
        },
        body: [{title: '开启微信用户信息授权，即可享受更多服务哦~', itemClass: 'size no-lh-x'}],
      },
      direction: type,
      actionSideWrapClass: 'itoast',
      animate: true,
    }))
  },
  onClose(e, params, inst){
    this.modal.onHide()
  },
  onShow: function () {},
  onReady: function () {
  },
  onLoad: function () {
    this.modal = this.getElementsById('actionSide1')
    this.modal2 = this.getElementsById('actionSide2')
  }
})
